<template>
	<view class="orderListWrapper">
		<view @click="gotoInfo(e)" class="item" v-for="(e,i) in orderList" :key="i">
			<!-- <view class="type">{{typeList[e.type]}}</view> -->
			<view class="info">
				<view class="infoItem">
					<view class="title">表单类型：</view>
					<view class="value people">{{typeList[e.type]}}</view>
				</view>
				<view class="infoItem">
					<view class="title">点检时间：</view>
					<view class="value">{{getDate(e.recordTime)}}</view>
				</view>
				<view class="infoItem">
					<view class="title">设备名称：</view>
					<view class="value name">{{e.industrialEquipmentName}}</view>
				</view>
				<view class="infoItem">
					<view class="title">点检人：</view>
					<view class="value people">{{e.operationEmployeeName}}</view>
				</view>
				<view class="infoItem">
					<view class="title">审核状态：</view>
					<view class="value">{{getStatusText(e.status)}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				typeList:[],
				orderList:[],
				pageNum:1,
				pageSize:10,
				title:'',
				TypeIdChild:'',
				dataSources:'',
				typeString:0,
			}
		},
		onLoad(e) {
			console.log(e);
			this.title = e.name
			this.TypeIdChild = e.id
			this.dataSources = e.dataSources
			uni.setNavigationBarTitle({
				title:e.name
			})
			this.getListALL()
		},
		onReachBottom(){
			this.pageNum++
			this.getdata()
		},
		methods: {
			getListALL(){
				const listallPar ={
					openid:uni.getStorageSync('openid'),
					param:`{"formTypeIdChild":${this.TypeIdChild}}`,
				}
				this.$u.api.getListALL(listallPar).then(listAll => {
					const types = []
					listAll.list.forEach(e=>{
						types.push(e.formId)
						this.typeList[e.formId] = e.formName
					})
					if(types.length>0){
						this.typeString = types.join(',')
					}
					this.getdata()
				})
			},
			getDate(res){
				//返回  yyyy-mm-dd hh-mm-ss格式的时间
				const date = new Date(res)
				const year = date.getFullYear()
				const month = date.getMonth()+1
				const day = date.getDate()
				const hour = date.getHours()
				const minute = date.getMinutes()
				const second = date.getSeconds()
				return `${year}-${month}-${day} ${hour}:${minute}:${second}`
			},
			getStatusText(index){
				const list = ['待审核','合格','不合格']
				return list[index]
			},
			getdata(){
				const param ={
					types : this.typeString,
				}
				if(this.TypeIdChild==5){
					param.dataSources = this.dataSources
				}
				const  par  = {
					openid:uni.getStorageSync('openid'),
					pageNum:this.pageNum,
					// param:`{"orderBy":"record_time","sort":"desc","types":"${this.typeString}"}`,
					param:JSON.stringify(param),
					pageSize:this.pageSize,
				}
				this.$u.api.getOrderList(par).then(res => {
					if(res.code==200){
						this.orderList =  this.orderList.concat(res.rows)
						uni.setNavigationBarTitle({
							title:`${this.title}(${res.total})条`
						})
					}
				})
			},
			gotoInfo(e){
				uni.navigateTo({
					url: `/subPages/FillWorkOrder/orderInfo?id=${e.id}&name=${this.typeList[e.type]}`
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.orderListWrapper{
		width: 100%;
		box-sizing: border-box;
		padding: 30rpx;
		background-color: #f4f7fe;
		.item{
			width: 100%;
			box-sizing: border-box;
			padding: 20rpx;
			background-color: #fff;
			margin-bottom: 20rpx;
			border-radius: 20rpx;
			.info{
				width: 100%;
				.infoItem{
					width: 100%;
					display: flex;
					justify-content: space-between;
					align-items: center;
					height: 60rpx;
					.title{
						color: #000;
					}
					.value{
						width: 60%;
						color: #dbdbdb;
					}
					.people{
						color: #787393;
					}
					.name{
						color: #7187a5;
					}
					&:last-child{
						border-top: 2rpx solid #ededed;
						margin-top: 40rpx;
						.value{
							color: #000;
						}
					}
				}
			}
		}
	}
</style>